import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		openid: uni.getStorageSync('openid') || '',
		token: uni.getStorageSync('token') || '',
		wxUserInfo: {},
		wxNickName:{},
		isShowAd:false,
		isShowAdTime: 0,
		logId:'',
		indexAd: true,
		activityAd: true,
		userAd: true,
		rankAd: true,
		userId: uni.getStorageSync('userId') || '',
		shareId: uni.getStorageSync('shareId') || '',
	},
	getters: {
		getToken: state => state.token,
		getOpenId: state => state.openid,
		wxUserInfo: state => state.wxUserInfo,
		wxNickName:state => state.wxNickName,
		getLogId:state => state.logId,

	},
	mutations: {
		setToken(state,flag) {
			state.token = flag.data;
			uni.setStorageSync('token', state.token);
		},
		setNumberIsWhat(state, number) {
			// 增加一个带参数的mutations方法
			state.number = number;
		},
	}
});


// 将 store 实例作为插件安装
export default store;